/*
 * @Author: your name
 * @Date: 2021-12-27 17:57:41
 * @LastEditTime: 2021-12-27 21:02:12
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geek-pc\src\store\reducers\login.js
 */
import { getToken } from "@/utils/token"
import { LOGIN, LOGOUT } from "../constants"

const init = {
    token: getToken()
}

export default function login(state = init, action) {
    if (action.type === LOGIN) {
        return {
            ...state,
            token: action.payload
        }
    }
    if (action.type === LOGOUT) {
        return {
            ...state,
            token: ''
        }
    }
    return state
}